Search
Berlin

Data for Berlin

Data for the city of Berlin are periodically reported from the Landesamt für Gesundheit und Soziales of the Berlin Council.

# for plotly
from plotly.offline import iplot
from plotly.offline import init_notebook_mode, plot
from IPython.core.display import display, HTML
import plotly as py
import plotly.tools as tls

import datetime
import numpy as np
import pandas as pd
from hedera_covid import DataHandler, smooth_data, plot_death_rate, plot_daily_cases, plot_confirmed_cases

# load data
berlin_data = '../../DE-Data/data-fIw01.csv'
berlin = pd.read_csv(berlin_data)
berlin.columns = ['date','confirmed','treated','intensive','deaths']

# preparation
N = len(berlin['date'])
dates = []
for d in berlin['date']:
    dt = datetime.datetime(int(d[6:10]),int(d[3:5]),int(d[0:2]))
    dates.append(dt.strftime('%d %b'))

confirmed_daily = []
deaths_daily = []

confirmed_daily.append(0)
deaths_daily.append(0)

for i in range(0,N-1):
    confirmed_daily.append(berlin['confirmed'][i+1]-berlin['confirmed'][i])
    deaths_daily.append(berlin['deaths'][i+1]-berlin['deaths'][i])
    
confirmed = smooth_data(berlin['confirmed'],n=7)
serious = smooth_data(berlin['intensive'],n=3)
deaths = smooth_data(berlin['deaths'],n=3)
treated = smooth_data(berlin['treated'],n=3) 



# intensive care
berlin_h = pd.read_excel('../../DE-Data/intensive-care-data.xlsx',sheet_name = 'berlin')
germany_h = pd.read_excel('../../DE-Data/intensive-care-data.xlsx',sheet_name = 'germany')
bayern_h = pd.read_excel('../../DE-Data/intensive-care-data.xlsx',sheet_name = 'bayern')



    
    

Outbreak over time

import plotly.graph_objects as go
init_notebook_mode(connected=True)

fig = go.Figure()


fig.add_trace(go.Bar(
    x=dates,
    y=confirmed,
    name='Reported Cases (Total = ' + str(berlin['confirmed'][N-1]) + ')'
))
fig.add_trace(go.Bar(
    x=dates,
    y=deaths,
    name='Reported Deaths (Total = ' + str(berlin['deaths'][N-1]) + ')'
))


fig.add_trace(go.Scatter(
    x=dates,
    y=serious,
    name='Intensive Care (Total = ' + str(berlin['intensive'][N-1]) + ')'
))
    
fig.update_layout(xaxis_tickangle=-90)

plot(fig, filename = 'figure.html')
display(HTML('figure.html'))

Daily variation

import plotly.graph_objects as go
init_notebook_mode(connected=True)

fig = go.Figure()


fig.add_trace(go.Bar(
    x=dates,
    y=confirmed_daily,
    name='Daily Reported Cases (Total = ' + str(berlin['confirmed'][N-1]) + ')',
    marker = {'color': "#117A65"}
))
n_smooth = 7
fig.add_trace(go.Scatter(
    x=dates,
    y=smooth_data(confirmed_daily,n=n_smooth),
    name='Averaged over ' + str(n_smooth) + ' days',
    marker = {'color': "#48C9B0"}
))


fig.add_trace(go.Bar(
    x=dates,
    y=deaths_daily,
    name='Daily Reported Deaths (Total = ' + str(berlin['deaths'][N-1]) + ')',
    marker = {'color':'#F7DC6F'}
))

n_smooth = 3
fig.add_trace(go.Scatter(
    x=dates,
    y=smooth_data(deaths_daily,n=n_smooth),
    name='Averaged over ' + str(n_smooth) + ' days',
    marker = {'color': "#EB984E"}
))
    
fig.update_layout(xaxis_tickangle=-90)
fig.update_layout(legend=dict(x=0.1, y=1.1),legend_orientation="h")


plot(fig, filename = 'figure.html')
display(HTML('figure.html'))

Capacity of intensive care

Some hospitals report periodically data about the availability of intensive care beds and of currently treated patients. The data for Berlin are shown below, compared with other federal states and with the overall national statistics.

Note The graphics take into account only the reporting entities (about 70% of the total)

import plotly.graph_objects as go
init_notebook_mode(connected=True)

fig = go.Figure()


fig.add_trace(go.Bar(
    x=berlin_h['Date'],
    y=berlin_h['Percentage'],
    name='Berlin',
    marker = {'color': "#117A65"}
))
fig.add_trace(go.Bar(
    x=germany_h['Date'],
    y=germany_h['Percentage'],
    name='Germany',
    marker = {'color': "#F7DC6F"}
))
fig.add_trace(go.Bar(
    x=bayern_h['Date'],
    y=bayern_h['Percentage'],
    name='Bayern',
    marker = {'color': "#48C9B0"}
))


fig.update_layout(xaxis_tickangle=-90)
fig.update_layout(title='Percentage of intensive beds free',legend=dict(x=0.1, y=1.1),legend_orientation="h")

#fig.show()
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))